package com.CloudDream.Gui.gui;

import com.CloudDream.Gui.MYInventoryHolder;
import com.CloudDream.Inventory.InventoryItem;
import com.CloudDream.Inventory.InventorySlot;
import com.CloudDream.Item.Creator;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

public class RecipeGui {
    public static final int[] Slots = new int[]{10, 11, 12, 19, 21, 28, 29, 30};

    public static Inventory open(Player p, String moonCake) {

        MYInventoryHolder holder = new MYInventoryHolder(p, 1);
        InventoryItem inventoryItem = new InventoryItem();
        Inventory inv = Bukkit.createInventory(holder, 54, "§bMoonCake §7- §a月饼合成展示");
        
        ItemStack Item = new Creator(XMaterial.GRAY_STAINED_GLASS_PANE.parseMaterial(), "&7", null, 7, false).get();

        for(int i = 0; i < 54; i++){
            for(int slot : Slots){
                inv.setItem(slot, InventoryItem.getMaterial(0));
                if(i != slot){
                    inv.setItem(i, Item);
                }
            }
        }
        inv.setItem(49, new Creator(XMaterial.BARRIER.parseMaterial() , "§c关闭", null, 0, false).get());
        switch(moonCake){
            case "lr":
                inv.setItem(20, InventoryItem.getMaterial(11));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.LR);
                break;
            case "wuren":
                inv.setItem(20, InventoryItem.getMaterial(13));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.WUREN);
                break;
            case "dh":
                inv.setItem(20, InventoryItem.getMaterial(12));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.DH);
                break;
            case "bt":
                inv.setItem(20, InventoryItem.getMaterial(7));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.BT);
                break;
            case "gw":
                inv.setItem(20, InventoryItem.getMaterial(9));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.GW);
                break;
            case "rs":
                inv.setItem(20, InventoryItem.getMaterial(10));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.RS);
                break;
            case "mg":
                inv.setItem(20, InventoryItem.getMaterial(8));
                inv.setItem(InventorySlot.MoonCake_Location, inventoryItem.MG);
                break;
        }
        inv.setItem(InventorySlot.WB_Location, inventoryItem.TABLE);

        return inv;

    }
}
